//获取最短距离的可用门店信息
const express=require('express');
const db=require('../utils/db.js');

const router=express.Router();

//获取可用门店最短距离
router.post('/minhall',(req,res)=>{
	const sql=`SELECT min(awaitNumber) as mindis FROM dininghall;`
	db.query(sql,(err,data)=>{
		if(err){
			res.send({msg:err})
		}else{
			// console.log("hallmindis:",data)
			res.send({data:data})
		}
	})
})


//获取最短距离门店的信息
router.post('/hallmindis',(req,res)=>{
	const sql=`SELECT * FROM dininghall where awaitNumber <= '${req.body.minDistance}';`;
	db.query(sql,(err,data)=>{
		if(err){
			res.send({msg:err})
		}else{
			console.log("hallmindis:",data)
			res.send({data:data})
		}
	})
})

module.exports=router;